package com.d0305;

public class MethodOverload {
     /*int square(int x) {
         return x*x ;
     }*/
     /*long square(long x){
         return x*x;
     }//因为Long的范围比int大，所以要用long square定义，
      // 而short范围比int小，所以可以用int square(short x)*/

    /*double square(double x){
        return x*x;
     }*/
    int  square(short x)
    {
        System.out.println("square(short x)");
        return x*x;
    }
    String square(String x)
    {
        System.out.println("square(long x)");
        return x;
    }

    public static void main(String[] args) {
        MethodOverload m=new MethodOverload();
        //System.out.println(m.square((short)3));//如果实参大于形参；则需要对实参的类型进行转换
        //System.out.println(m.square(3.0));
        System.out.println(m.square(("3")));//字符串重载
    }

}


